<template>
	<view class="content">
		<uni-nav-bar v-if="!isApp" left-icon="back" title="邀请记录" shadow="false" @click-left="back()" :fixed="true"></uni-nav-bar>
		<view class="myInvitation" :style="{ 'padding-top': isApp ? '0' : '88upx' }">
      <view class="myInvitation_header">
        <view class="header_title">我的邀请人数(未认证账户将无法获得奖励)</view>
        <view class="header_number">
          <text class="number">{{list.length}}</text>
          <text class="coin">人</text>
        </view>
        <view class="header_go" @click="goPage('../../invitation/invitation')">去邀请</view>
      </view>
      <!-- <view class="myInvitation_nav">
        <view class="flex">
          <text style="color: #000000; font-size: 40upx;">排名</text>
          <text style="color: #333333; font-size: 26upx;">及奖励</text>
        </view>
        <view class="flex">第 7 名</view>
        <view class="flex" style="align-items: flex-end;">+20.56 CRL</view>
      </view> -->
      <view class="bg"></view>
      <view class="list_main">
        <view class="item" v-for="(item, index) in list" :key="index">
          <view class="item_img_number">
            <view style="font-family: '黑体'; font-size: 34upx; font-weight: bold; color: #717171;">{{index + 1}}</view>
          </view>
          <view class="item_account">{{REG_EMAIL.test(item.account) ? filter.email(item.account) : filter.getSuffixPhone(item.account)}}{{item.authFlag == 'INIT' ? '(未认证)':''}}</view>
          <view class="item_profit" style="max-width: 160rpx;">
            <text class="coin">{{$formta(item.createTime,'yyyy-MM-dd')}}</text>
          </view>
        </view>
        <uni-load-more :status="loading ? 'loading' : !list[0] ? 'noMore' : 'noMore'"></uni-load-more>
      </view>
      <HMmessages ref="HMmessages" @complete="HMmessages = $refs.HMmessages" @clickMessage="clickMessage"></HMmessages>
    </view>
	</view>
</template>

<script>
  import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue';
  import service from '../service.js'
  import { uniLoadMore } from '@dcloudio/uni-ui';
  import HMmessages from '@/components/HM-messages/HM-messages.vue';
  import filter from '@/common/filter.js';
  import {REG_EMAIL} from '@/common/reg.js';
	export default {
    components: { uniNavBar ,
    uniLoadMore,
    HMmessages},
		data() {
			return {
        REG_EMAIL,
        filter,
				isApp: uni.getStorageSync('isAppH5'),
        list:[],
        loading:true,
			};
		},
    onShow() {
      this.getInviteList();
    },
    methods:{
      //获取邀请列表
      getInviteList(){
        this.loading = true;
        service.getInviteList().then(({data})=>{
          this.loading = false;
          if(data.code == '100200'){
            this.list = data.data;
          }else{
            this.errors(data.msg);
          }
        })
      },
      //错误提示
      errors(text) {
        this.HMmessages.show(text, {
          textAlign: 'center',
          background: '#74272d',
          fontColor: '#fff'
        });
      },
      goPage(url){
        uni.navigateTo({
          url:url
        })
      },
      //修改手机返回
      back() {
        let length = getCurrentPages();
        if (length.length == 1) {
          uni.switchTab({
            url: '../../index/index'
          });
        } else {
          uni.navigateBack();
        }
      }
    }
	}
</script>

<style lang="scss">
@import './style.scss';
</style>
